package com.lqs.blog.controller;

import com.lqs.blog.pojo.Tag;
import com.lqs.blog.service.TagService;
import com.lqs.blog.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;
import java.util.List;

@RestController
@RequestMapping("tags")
public class TagController {
    @Autowired
    private TagService tagService;

    @GetMapping("hot")
    public Result hot() {
        //查询文章的标签最多使用前六个标签
        int limit = 6;
        return tagService.hots(limit);//获取排名前六的标签id
    }

    @GetMapping
    public Result tags() {
        return tagService.getTags();
    }

    @GetMapping("detail")
    public Result tagDetail() {
        return tagService.getTagDetail();
    }

    @GetMapping("detail/{id}")
    public Result tagDetail(@PathVariable("id") Long id) {
        return tagService.getTagById(id);
    }
}
